package com.example.weatherpromax

import android.media.Image
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.ImageView
import android.widget.TextView
import androidx.recyclerview.widget.RecyclerView

class hourAdapter (val hourList:List<weather_today>):RecyclerView.Adapter<hourAdapter.ViewHolder>(){

    inner class ViewHolder(view:View):RecyclerView.ViewHolder(view){
        val temp_hour : TextView = view.findViewById(R.id.temp_hour)
        val weather_icon : ImageView =view.findViewById(R.id.weather_icon)
    }

    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
       val view = LayoutInflater.from(parent.context).inflate(R.layout.item_hourly_weather,parent,false)
        return  ViewHolder(view)
    }

    override fun onBindViewHolder(holder: ViewHolder, position: Int) {
        val hourList = hourList[position]
        holder.temp_hour.text = hourList.temperature
        holder.weather_icon.setImageResource((hourList.weatherIcon))
    }

    override fun getItemCount() = hourList.size
    }
